<!doctype html>
<html class="no-js " lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta HTTP-EQUIV="pragma" CONTENT="no-cache">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta name="description" content="Responsive Bootstrap 4 and web Application ui kit.">
    <title>平顶山学院附属口腔医院</title>
    <link rel="icon" href="/favicon.ico" type="image/x-icon">
    <!-- Favicon-->
    <link rel="stylesheet" href="/assets/plugins/bootstrap/css/bootstrap.min.css">
    <!--文件上传样式-->
    <link rel="stylesheet" href="/assets/plugins/dropzone/dropzone.css">
    <link rel="stylesheet" href="/assets/plugins/bootstrap-select/css/bootstrap-select.css"/>
    <link rel="stylesheet" href="/assets/plugins/jvectormap/jquery-jvectormap-2.0.3.min.css"/>
    <link rel="stylesheet" href="/assets/plugins/morrisjs/morris.min.css" />
    <!--时间线样式-->
    <link rel="stylesheet" href="/assets/css/timeline.css">
    <!--主要样式-->
    <link rel="stylesheet" href="/assets/css/main.css">
    <!--皮肤样式-->
    <link rel="stylesheet" href="/assets/css/color_skins.css">
<!--图片显示样式-->
    <link rel="stylesheet" href="/assets/plugins/light-gallery/css/lightgallery.css">
</head>
<body class="theme-cyan">
<!-- Page Loader -->
<div class="page-loader-wrapper">
    <div class="loader">
        <div class="m-t-30"><img class="zmdi-hc-spin" src="/assets/images/logo.svg" width="48" height="48" alt="Compass"></div>
        <p>Please wait...</p>
    </div>
</div>
<!-- Overlay For Sidebars -->
<div class="overlay"></div>

<!-- Top Bar -->
<div th:replace="~{common/common :: commonBar}"></div>

<!-- Left Sidebar -->
<div th:replace="~{common/common :: commonLeft}"></div>

<!-- Right Sidebar -->
<div th:replace="~{common/common :: commonRight}"></div>

<!-- Main Content -->
    <section class="content" id="section_context_main">
        <div th:replace="~{doctors :: doctors}"></div>
        <div th:replace="~{add-doctor :: add-doctor}"></div>
        <div th:replace="~{patients :: patients}"></div>
        <div th:replace="~{add-patient :: add-patient}"></div>
        <div th:replace="~{update-doctor :: update-doctor }"></div>
        <div th:replace="~{update-patient :: #update-patient}"></div>
        <div th:replace="~{patient-profile :: patient-profile}"></div>
        <div th:replace="~{update-person :: update-person}"></div>
    </section>


<!-- Jquery Core Js -->
<script src="/assets/bundles/libscripts.bundle.js"></script> <!-- Lib Scripts Plugin Js ( jquery.v3.2.1, Bootstrap4 js) -->
<script src="/assets/bundles/vendorscripts.bundle.js"></script> <!-- slimscroll, waves Scripts Plugin Js -->
<script src="/assets/bundles/morrisscripts.bundle.js"></script><!-- Morris Plugin Js -->
<script src="/assets/bundles/jvectormap.bundle.js"></script> <!-- JVectorMap Plugin Js -->
<script src="/assets/bundles/knob.bundle.js"></script> <!-- Jquery Knob Plugin Js -->
<script src="/assets/bundles/countTo.bundle.js"></script> <!-- Jquery CountTo Plugin Js -->
<script src="/assets/bundles/sparkline.bundle.js"></script> <!-- Sparkline Plugin Js -->
<script src="/assets/bundles/mainscripts.bundle.js"></script>
<script src="/assets/js/pages/index.js"></script>
<script src="/assets/plugins/dropzone/dropzone.js"></script> <!-- Dropzone Plugin Js -->
<script src="/assets/js/pages/charts/jquery-knob.js"></script>
<script src="/assets/plugins/light-gallery/js/lightgallery-all.min.js"></script> <!-- Light Gallery Plugin Js -->
<script src="/assets/js/pages/medias/image-gallery.js"></script>
<script th:replace="~{common/common :: commonJs}"></script>

<!--    docotrs 页面-->
<script type="text/javascript">
    $(function () {
        showList(1);
    })

    // 动态显示医生内容
    function showList(pageNo) {
        var searchName = $("#doctor_name").val()
        var pageSize = 10
        $("#doctor-list").empty();//显示前 清空原列表
        $("#message").hide()
        $.ajax({
            url: "/hospital/doctors/list",
            type: "post",
            dataType: "json",
            data: JSON.stringify({
                page_num: pageNo,
                page_size: pageSize,
                search_name: searchName
            }),
            contentType: "application/json;charset=utf-8",
            success: function (data) {
                if (data.code === 200) {
                    var page = data.data;
                    var list = page.records;
                    console.log(list)
                    if (list.length === 0) {
                        showList(pageNo - 1)
                        return
                    }
                    var res = [];
                    for (var i = 0; i < list.length; i++) {
                        res.push('<tr>');
                        res.push('<td><span class="list-icon"><img class="patients-img" src="' + list[i].image + '"></span>')
                        res.push('<td align="center" >' + list[i].id + '</td>');
                        res.push('<td><span class="list-name">' + list[i].userName + '</span></td>')
                        res.push('<td>' + list[i].password + '</td>')
                        res.push('<td><span class="list-name">' + list[i].realName + '</span></td>')
                        if (list[i].perms === 'admin') {
                            res.push('<td>管理员</td>')
                        } else {
                            res.push('<td>用户</td>')
                        }
                        res.push('<td>' + list[i].createTime.replace("T"," ") + '</td>')
                        res.push('<td>' + list[i].updateTime.replace("T"," ") + '</td>')
                        if (list[i].status === 1) {
                            res.push('<td><button type="button" class="btn btn-sm btn-success" id="statusButton' + list[i].id + '" value="1" onclick="changeStatus(this.value,'+ list[i].id +')">启用</button></td>')
                        } else {
                            res.push('<td><button type="button" class="btn btn-sm btn-dange" id="statusButton' + list[i].id + '" value="0" onclick="changeStatus(this.value,'+ list[i].id +')">禁用</button></td>')
                        }
                        res.push('<td><button type="button" class="btn btn-sm btn-info" value="'+ list[i].id + '" data-toggle="update-doctor" onclick="d_selectDoctor(this.value)">修改</button>')
                        res.push('<button type="button" class="btn btn-sm btn-danger" value="' + list[i].id + '" onclick="deleteDoctor(this.value)">删除</button></td>')
                        res.push('</tr>');
                    }
                    $("#doctor-list").html(res.join(""))
                    var a = document.getElementById("doctor-list").getElementsByTagName("tr");
                    var zz = new Array(a.length);
                    for (var i = 0; i < a.length; i++) {
                        zz[i] = a[i].innerHTML
                    } //div的字符串数组付给z
                    var pageno = pageNo;               //当前页
                    var pagesize = pageSize;            //每页多少条信息
                    var pageall = page.pages;
                    $("#doctor_pages").text(pageall);      //将总页数的值存放到div中，便于下次使用
                    $("#doctor_total").text(page.total);      //将总记录数的值存放到div中，便于下次使用
                    change(page.current, page.pages, page.size, page.total);
                } else {
                    $("#message").show()
                    $("#message").val(data.message).html()
                }
            }
        })
    }

    function change(e, pages, size, total) {
        var pagesize = size;   //每页多少条信息
        pageall = pages;     //总页数
        pageno = e;        //当前页
        if (e < 1)//如果输入页<1页
        {
            e = 1;
            pageno = 1
        }//就等于第1页 ， 当前页为1
        if (e > pageall)//如果输入页大于最大页
        {
            e = pageall;
            pageno = pageall
        }//输入页和当前页都=最大页
        var ye = "";
        for (var j = 1; j <= pageall; j++) {
            if (e == j) {
                ye = ye + "<span><a href='#' onClick='change1(" + j + ")' class='page-item active'>" + j + "</a></span> "
            } else {
                ye = ye + "<a href='#' class='page-item' onClick='change1(" + j + ")'>" + j + "</a> "
            }
        }
        document.getElementById("d_pageall").innerHTML = pageall;
        document.getElementById("d_pageno").innerHTML = pageno;
        document.getElementById("d_pagenum").innerHTML = ye;
        document.getElementById("d_total").innerHTML = total

        /*如果当前是第一页则：*/

        if (pageno === 1) {
            $('#down').hide();//隐藏
        } else {
            $('#down').show();//显示
        }

        /*如果是最后一页则：*/

        if (pageno === pageall) {
            $('#up').hide();//隐藏
        } else {
            $('#up').show();//显示
        }
        //  如果没有数据
        if (pageno === 0 && pageall === 0) {
            $('#up').hide();//隐藏
            $('#down').hide();//隐藏
        }

    }

    function change1(e) {
        pageall = $("#doctor_pages").text();
        pageno = e;
        /*如果当前是第一页则：*/
        if (e < 1)//如果输入页<1页
        {
            e = 1;
            pageno = 1
        }//就等于第1页 ， 当前页为1
        if (e > pageall)//如果输入页大于最大页
        {
            e = pageall;
            pageno = pageall
        }//输入页和当前页都=最大页

        showList(pageno)

        if (pageno === 1) {
            $('#down').hide();//隐藏
        } else {
            $('#down').show();//显示
        }

        /*如果是最后一页则：*/

        if (pageno === pageall) {
            $('#up').hide();//隐藏
        } else {
            $('#up').show();//显示
        }
    }


    $("#doctor_name").keydown(function (e) {
        if (e.keyCode === 13) {
            showList(1)
        }
    });


    function deleteDoctor(value) {
        if (confirm("是否要删除？")) {
            $.ajax({
                url: "/hospital/doctors/delete",
                type: "delete",
                data: {
                    id: value
                },
                success: function (data) {
                    if (data.code === 200) {
                        alert(data.msg)
                        showList(document.getElementById("a2").innerHTML);
                    } else {
                        alert(data.msg)
                    }
                }
            })
        }
    }


    // 更改状态
    function changeStatus(status, id) {
        $.ajax({
            type: "post",
            url: "/hospital/doctors/changeStatus",
            dataType: "json",
            data: JSON.stringify({
                id: id,
                status: status
            }),
            contentType: "application/json;charset=utf-8",
            success: function (data) {
                if (data.code === 200) {
                    alert(data.msg)
                    if (data.data === 0) {
                        showList(document.getElementById("d_pageno").innerHTML);
                    } else if (data.data === 1) {
                        showList(document.getElementById("d_pageno").innerHTML);
                    }
                } else {
                    alert(data.msg)
                }
            }
        })
    }

    // 解决 Uncaught Error: Dropzone already attached.
    Dropzone.autoDiscover = false;
    $('#Modal').on('hidden.bs.modal', function () {
        applyZone.destroy();
    });

    //添加医生的上传
    $("#frmFileUpload").dropzone({
        url: '/hospital/doctors/upload',
        method: "post",  //也可用put
        paramName: "file",
        maxFilesize: 10.0, // 上传的文件大小
        maxFiles: 1,//一次性上传的文件数量上限
        acceptedFiles: ".jpg,.gif,.png,.jpeg",
        addRemoveLinks: true,//添加移除文件
        autoProcessQueue: true,//自动上传
        dictCancelUploadConfirmation: '你确定要取消上传吗？',
        dictMaxFilesExceeded: "只能上传{{maxFiles}}个文件",
        dictFileTooBig: "文件过大({{filesize}}MB). 上传文件最大支持: {{maxFilesize}}MB.",
        dictDefaultMessage:
            '<span class="bigger-150 bolder"><i class="icon-caret-right red"></i> 拖动文件至该处</span> \
            <span class="smaller-80 grey"></span> <br /> \
            <i class="upload-icon icon-cloud-upload blue icon-3x"></i>',
        dictResponseError: '文件上传失败!',
        dictInvalidFileType: "文件类型只能是*.jpg,*.gif,*.png,*.jpeg。",
        dictCancelUpload: "取消上传",
        dictRemoveFile: "移除文件",
        uploadMultiple: false,
        init: function () {
            //上传文件时触发的事件
            this.on("addedfile", function (file) {
                //浏览器控制台输出js
                console.log("File " + file.name + "uploaded");
            });
            //上传文件成功时触发的事件
            this.on("success", function (file, data) {
                console.log("File " + file.name + "uploaded");
                $("#d_filename").val(data.data)
                console.log(data.data)
            });
            //移除文件触发的事件
            this.on("removedfile", function (file) {
                var fileName = $("#d_filename").val()
                deleteUpload2(fileName)
                console.log("File " + file.name + "removed");
            });
        }
    });

    //修改医生的上传
    $("#frmFileUpload1").dropzone({
        url: '/hospital/doctors/upload',
        method: "post",  //也可用put
        paramName: "file",
        maxFilesize: 10.0, // 上传的文件大小
        maxFiles: 1,//一次性上传的文件数量上限
        acceptedFiles: ".jpg,.gif,.png,.jpeg",
        addRemoveLinks: true,//添加移除文件
        autoProcessQueue: true,//自动上传
        dictCancelUploadConfirmation: '你确定要取消上传吗？',
        dictMaxFilesExceeded: "只能上传{{maxFiles}}个文件",
        dictFileTooBig: "文件过大({{filesize}}MB). 上传文件最大支持: {{maxFilesize}}MB.",
        dictDefaultMessage:
            '<span class="bigger-150 bolder"><i class="icon-caret-right red"></i> 拖动文件至该处</span> \
            <span class="smaller-80 grey"></span> <br /> \
            <i class="upload-icon icon-cloud-upload blue icon-3x"></i>',
        dictResponseError: '文件上传失败!',
        dictInvalidFileType: "文件类型只能是*.jpg,*.gif,*.png,*.jpeg。",
        dictCancelUpload: "取消上传",
        dictRemoveFile: "移除文件",
        uploadMultiple: false,
        init: function () {
            //上传文件时触发的事件
            this.on("addedfile", function (file) {
                //浏览器控制台输出js
                console.log("File " + file.name + "uploaded");
            });
            //上传文件成功时触发的事件
            this.on("success", function (file, data) {
                console.log("File " + file.name + "uploaded");
                $("#d_filename1").val(data.data)
                console.log(data.data)
            });
            //移除文件触发的事件
            this.on("removedfile", function (file) {
                var fileName = $("#d_filename1").val()
                deleteUpload2(fileName)
                console.log("File " + file.name + "removed");
            });
        }
    });


    //修改自己信息的上传
    $("#person_frmFileUpload").dropzone({
        url: '/hospital/doctors/upload',
        method: "post",  //也可用put
        paramName: "file",
        maxFilesize: 10.0, // 上传的文件大小
        maxFiles: 1,//一次性上传的文件数量上限
        acceptedFiles: ".jpg,.gif,.png,.jpeg",
        addRemoveLinks: true,//添加移除文件
        autoProcessQueue: true,//自动上传
        dictCancelUploadConfirmation: '你确定要取消上传吗？',
        dictMaxFilesExceeded: "只能上传{{maxFiles}}个文件",
        dictFileTooBig: "文件过大({{filesize}}MB). 上传文件最大支持: {{maxFilesize}}MB.",
        dictDefaultMessage:
            '<span class="bigger-150 bolder"><i class="icon-caret-right red"></i> 拖动文件至该处</span> \
            <span class="smaller-80 grey"></span> <br /> \
            <i class="upload-icon icon-cloud-upload blue icon-3x"></i>',
        dictResponseError: '文件上传失败!',
        dictInvalidFileType: "文件类型只能是*.jpg,*.gif,*.png,*.jpeg。",
        dictCancelUpload: "取消上传",
        dictRemoveFile: "移除文件",
        uploadMultiple: false,
        init: function () {
            //上传文件时触发的事件
            this.on("addedfile", function (file) {
                //浏览器控制台输出js
                console.log("File " + file.name + "uploaded");
            });
            //上传文件成功时触发的事件
            this.on("success", function (file, data) {
                console.log("File " + file.name + "uploaded");
                $("#person_filename").val(data.data)
                console.log(data.data)
            });
            //移除文件触发的事件
            this.on("removedfile", function (file) {
                var fileName = $("#person_filename").val()
                deleteUpload2(fileName)
                console.log("File " + file.name + "removed");
            });
        }
    });


    // 删除医生的图片
    function deleteUpload2(fileName) {
        alert(fileName)
        $.ajax({
            url: "/hospital/doctors/deletePicture",
            type: "delete",
            data: {
                fileName: fileName
            },
            success: function (data) {
                alert(data.data)
            }
        })
    }

    // 添加医生信息
    function addDoctor() {
        var userName = $("#d_username").val()
        var password = $("#d_password").val()
        var realName = $("#d_realname").val()
        var status = $("#d_status").val()
        var perms = $("#d_perms").val()
        var image = $("#d_filename").val()
        if (typeof (userName) == 'undefined' || typeof (password) == 'undefined' || typeof (realName) == 'undefined' ||
            typeof (status) == 'undefined' || typeof (perms) == 'undefined' || typeof (image) == 'undefined') {
            alert("请填写完整信息！")
            return
        }
        if (userName === null || password === null || realName === null || status === null || perms === null || image === null) {
            alert("有未填写的信息！")
            return
        }
        var doctor = {
            userName: userName,
            password: password,
            realName: realName,
            status: status,
            perms: perms,
            image: image
        }
        $.ajax({
            url: "/hospital/doctors/add",
            type: "post",
            dataType: "json",
            data: JSON.stringify(doctor),
            contentType: "application/json;charset=utf-8",
            success: function (data) {
                if (data.code === 200) {
                    $("#d_username").val("")
                    $("#d_password").val("")
                    $("#d_realname").val("")
                    $("#d_status").val("")
                    $("#d_perms").val("")
                    $("#d_filename").val("")
                    alert("添加完成！")
                    backDoctors()
                    Dropzone.forElement("#frmFileUpload").removeAllFiles(true);
                } else {
                    alert(data.msg)
                    backDoctors()
                    Dropzone.forElement("#frmFileUpload").removeAllFiles(true);
                }
            }
        })
    }

    // 更新操作前查询
    function d_selectDoctor(id) {
        Dropzone.forElement("#frmFileUpload1").removeAllFiles(true);
        $("#d_image_show").innerHTML=""
        $.ajax({
            url: "/hospital/doctors/getOne/"+id,
            type: "get",
            dataType: "json",
            contentType: "application/json;charset=utf-8",
            success: function (data) {
                if (data.code === 200) {
                    showPage("update-doctor")
                    $("#d_id1").val(id)
                    $("#d_username1").val(data.data.userName)
                    $("#d_password1").val(data.data.password)
                    $("#d_realname1").val(data.data.realName)
                    $("#d_status1").selectpicker('val',data.data.status);
                    $("#d_perms1").selectpicker("val",data.data.perms)
                    var res = [];
                    res.push('<div class="col-xl-3 col-lg-4 col-md-6 col-sm-12 m-b-20">');
                    res.push('<a href=' + data.data.image + ' target="_blank">')
                    res.push('<img class="img-fluid img-thumbnail" id="d_image" value="'+data.data.image +'" src=' + data.data.image + ' alt="">')
                    res.push('</a>')
                    res.push('</div>');
                    $('#d_image_show').html(res.join(""))
                }else {
                    alert("出现错误，请重试")
                }
            }
        })
    }


    //更新医生信息
    function updateDoctor() {
        var id= $("#d_id1").val()
        var username = $("#d_username1").val()
        var password = $("#d_password1").val()
        var realname = $("#d_realname1").val()
        var status = $("#d_status1").val()
        var perms = $("#d_perms1").val()
        var image = ''
        if ($("#d_filename1").val() !== ""){
            image = $("#d_filename1").val()
        }else {
            image = $("#d_image").attr('value')
            console.log(image)
        }

        if (typeof (username) == 'undefined' || typeof (password) == 'undefined' || typeof (realname) == 'undefined' ||
            typeof (status) == 'undefined' || typeof (perms) == 'undefined' || typeof (image) == 'undefined') {
            alert("请填写完整信息！")
            return
        }
        if (username === null || password === null || realname === null || status === null || perms === null || image === null) {
            alert("有未填写的信息！")
            return
        }
        var doctor = {
            id:id,
            userName: username,
            password: password,
            realName: realname,
            status: status,
            perms: perms,
            image: image
        }
        $.ajax({
            url: "/hospital/doctors/update",
            type: "put",
            dataType: "json",
            data : JSON.stringify(doctor),
            contentType: "application/json;charset=utf-8",
            success: function (data) {
                if (data.code === 200){
                    if (data.data === 1){
                        document.getElementById ('photo').src=image;
                    }
                    if (image !== $("#d_image").attr("value")){
                        deleteUpload2($("#d_image").attr("value"))
                    }
                    $("#d_filename1").attr('value',"")
                    backDoctors()
                }else {
                    alert(data.message)
                    backDoctors()
                }
            }
        })
    }

    // 删除病人图片
    function deleteUpload(fileName) {
        alert(fileName)
        $.ajax({
            url: "/hospital/patients/deletePicture",
            type: "delete",
            data: {
                fileName: fileName
            },
            success: function (data) {
            }
        })
    }


</script>

<!--patients -->
<script>
    // 添加
    $("#frmFileUpload2").dropzone({
        url:'/hospital/patients/upload',
        method: "post",  //也可用put
        paramName: "file",
        maxFilesize: 20, // 单个文件上传的文件最大MB
        // maxFiles:50,//一次性上传的文件数量上限
        //一次上传的文件数量,关键；控制每次上传的并行数量，通过这个使每次上传一个后台一个一个接受文件如果修改为>1
        // 服务器如果无法处理会导致有的文件没上传到服务器
        parallelUploads: 1,
        uploadMultiple: true, //开启多文件上传
        acceptedFiles: ".jpg,.gif,.png,.jpeg,.webp",//支持的文件格式
        addRemoveLinks : true,//添加移除文件
        autoProcessQueue: true,//不自动上传
        dictCancelUploadConfirmation:'你确定要取消上传吗？',
        dictMaxFilesExceeded: "只能上传{{maxFiles}}个文件",
        dictFileTooBig:"文件过大({{filesize}}MB). 上传文件最大支持: {{maxFilesize}}MB.",
        dictDefaultMessage :
            '<span class="bigger-150 bolder"><i class="icon-caret-right red"></i> 拖动文件至该处</span> \
            <span class="smaller-80 grey"></span> <br /> \
            <i class="upload-icon icon-cloud-upload blue icon-3x"></i>',
        dictResponseError: '文件上传失败!',
        dictInvalidFileType: "文件类型只能是*.jpg,*.gif,*.png,*.jpeg,*.webp。",
        dictCancelUpload: "取消上传",
        dictRemoveFile: "移除文件",
        dictInvalidInputType:"文件类型必须是.jpg,.gif,.png,.jpeg,.webp",
        init: function() {
            //上传文件时触发的事件
            this.on("addedfile", function(file) {
                //浏览器控制台输出js
                console.log("File " + file.name + "uploaded");
            });
            //上传文件成功时触发的事件
            this.on("success", function(file,data) {
                console.log("File " + file.name + "uploaded");
                var temp = $("#p_filenames").val()
                if (temp === ''){
                    $("#p_filenames").val(file.name+","+data.data+";0")
                }else {
                    $("#p_filenames").val(temp+"&"+file.name+","+data.data+";0")
                }
                console.log(data.data)
            });
            //移除文件触发的事件
            this.on("removedfile", function(file) {
                console.log(file.name)
                var fileName = $("#p_filenames").val()
                var str = fileName.split("&")
                for (var i = 0; i < str.length; i++){
                    if (str[i].indexOf(file.name) !== -1){
                        var f = str[i].substr(str[i].indexOf(",")+1)
                        deleteUpload(f)
                        str.splice(i,1)
                        console.log("File " + f + "removed");
                    }
                }

            });
        }
    });

    // 修改治疗前
    $("#frmFileUpload3").dropzone({
        url:'/hospital/patients/upload',
        method: "post",  //也可用put
        paramName: "file",
        maxFilesize: 20.0, // 单个文件上传的文件最大MB
        // maxFiles:50,//一次性上传的文件数量上限
        //一次上传的文件数量,关键；控制每次上传的并行数量，通过这个使每次上传一个后台一个一个接受文件如果修改为>1
        // 服务器如果无法处理会导致有的文件没上传到服务器
        parallelUploads: 1,
        uploadMultiple: true, //开启多文件上传
        acceptedFiles: ".jpg,.gif,.png,.jpeg,.webp",//支持的文件格式
        addRemoveLinks : true,//添加移除文件
        autoProcessQueue: true,//不自动上传
        dictCancelUploadConfirmation:'你确定要取消上传吗？',
        dictMaxFilesExceeded: "只能上传{{maxFiles}}个文件",
        dictFileTooBig:"文件过大({{filesize}}MB). 上传文件最大支持: {{maxFilesize}}MB.",
        dictDefaultMessage :
            '<span class="bigger-150 bolder"><i class="icon-caret-right red"></i> 拖动文件至该处</span> \
            <span class="smaller-80 grey"></span> <br /> \
            <i class="upload-icon icon-cloud-upload blue icon-3x"></i>',
        dictResponseError: '文件上传失败!',
        dictInvalidFileType: "文件类型只能是*.jpg,*.gif,*.png,*.jpeg,*.webp。",
        dictCancelUpload: "取消上传",
        dictRemoveFile: "移除文件",
        dictInvalidInputType:"文件类型必须是.jpg,.gif,.png,.jpeg,.webp",
        init: function() {
            //上传文件时触发的事件
            this.on("addedfile", function(file) {
                //浏览器控制台输出js
                console.log("File " + file.name + "uploaded");
            });
            //上传文件成功时触发的事件
            this.on("success", function(file,data) {
                console.log("File " + file.name + "uploaded");
                var temp = $("#p_filenames_add").val()
                if (temp === ''){
                    $("#p_filenames_add").val(file.name+","+data.data+";0")
                }else {
                    $("#p_filenames_add").val(temp+"&"+file.name+","+data.data+";0")
                }
                console.log(data.data)
            });
            //移除文件触发的事件
            this.on("removedfile", function(file) {
                console.log(file.name)
                var fileName = $("#p_filenames_add").val()
                var str = fileName.split("&")
                for (var i = 0; i < str.length; i++){
                    if (str[i].indexOf(file.name) !== -1){
                        var f = str[i].substr(str[i].indexOf(",")+1)
                        deleteUpload(f)
                        str.splice(i,1)
                        console.log("File " + f + "removed");
                    }
                }

            });
        }
    });

    // 修改治疗中
    $("#frmFileUpload4").dropzone({
        url:'/hospital/patients/upload',
        method: "post",  //也可用put
        paramName: "file",
        maxFilesize: 20.0, // 单个文件上传的文件最大MB
        // maxFiles:50,//一次性上传的文件数量上限
        //一次上传的文件数量,关键；控制每次上传的并行数量，通过这个使每次上传一个后台一个一个接受文件如果修改为>1
        // 服务器如果无法处理会导致有的文件没上传到服务器
        parallelUploads: 1,
        uploadMultiple: true, //开启多文件上传
        acceptedFiles: ".jpg,.gif,.png,.jpeg,.webp",//支持的文件格式
        addRemoveLinks : true,//添加移除文件
        autoProcessQueue: true,//不自动上传
        dictCancelUploadConfirmation:'你确定要取消上传吗？',
        dictMaxFilesExceeded: "只能上传{{maxFiles}}个文件",
        dictFileTooBig:"文件过大({{filesize}}MB). 上传文件最大支持: {{maxFilesize}}MB.",
        dictDefaultMessage :
            '<span class="bigger-150 bolder"><i class="icon-caret-right red"></i> 拖动文件至该处</span> \
            <span class="smaller-80 grey"></span> <br /> \
            <i class="upload-icon icon-cloud-upload blue icon-3x"></i>',
        dictResponseError: '文件上传失败!',
        dictInvalidFileType: "文件类型只能是*.jpg,*.gif,*.png,*.jpeg,*.webp。",
        dictCancelUpload: "取消上传",
        dictRemoveFile: "移除文件",
        dictInvalidInputType:"文件类型必须是.jpg,.gif,.png,.jpeg,.webp",
        init: function() {
            //上传文件时触发的事件
            this.on("addedfile", function(file) {
                //浏览器控制台输出js
                console.log("File " + file.name + "uploaded");
            });
            //上传文件成功时触发的事件
            this.on("success", function(file,data) {
                console.log("File " + file.name + "uploaded");
                var temp = $("#p_filenames_add").val()
                if (temp === ''){
                    $("#p_filenames_add").val(file.name+","+data.data+";1")
                }else {
                    $("#p_filenames_add").val(temp+"&"+file.name+","+data.data+";1")
                }
                console.log(data.data)
            });
            //移除文件触发的事件
            this.on("removedfile", function(file) {
                console.log(file.name)
                var fileName = $("#p_filenames_add").val()
                var str = fileName.split("&")
                for (var i = 0; i < str.length; i++){
                    if (str[i].indexOf(file.name) !== -1){
                        var f = str[i].substr(str[i].indexOf(",")+1)
                        deleteUpload(f)
                        str.splice(i,1)
                        console.log("File " + f + "removed");
                    }
                }

            });
        }
    });

    // 修改治疗后
    $("#frmFileUpload5").dropzone({
        url:'/hospital/patients/upload',
        method: "post",  //也可用put
        paramName: "file",
        maxFilesize: 20.0, // 单个文件上传的文件最大MB
        // maxFiles:50,//一次性上传的文件数量上限
        //一次上传的文件数量,关键；控制每次上传的并行数量，通过这个使每次上传一个后台一个一个接受文件如果修改为>1
        // 服务器如果无法处理会导致有的文件没上传到服务器
        parallelUploads: 1,
        uploadMultiple: true, //开启多文件上传
        acceptedFiles: ".jpg,.gif,.png,.jpeg,.webp",//支持的文件格式
        addRemoveLinks : true,//添加移除文件
        autoProcessQueue: true,//不自动上传
        dictCancelUploadConfirmation:'你确定要取消上传吗？',
        dictMaxFilesExceeded: "只能上传{{maxFiles}}个文件",
        dictFileTooBig:"文件过大({{filesize}}MB). 上传文件最大支持: {{maxFilesize}}MB.",
        dictDefaultMessage :
            '<span class="bigger-150 bolder"><i class="icon-caret-right red"></i> 拖动文件至该处</span> \
            <span class="smaller-80 grey"></span> <br /> \
            <i class="upload-icon icon-cloud-upload blue icon-3x"></i>',
        dictResponseError: '文件上传失败!',
        dictInvalidFileType: "文件类型只能是*.jpg,*.gif,*.png,*.jpeg,*.webp。",
        dictCancelUpload: "取消上传",
        dictRemoveFile: "移除文件",
        dictInvalidInputType:"文件类型必须是.jpg,.gif,.png,.jpeg,.webp",
        init: function() {
            //上传文件时触发的事件
            this.on("addedfile", function(file) {
                //浏览器控制台输出js
                console.log("File " + file.name + "uploaded");
            });
            //上传文件成功时触发的事件
            this.on("success", function(file,data) {
                console.log("File " + file.name + "uploaded");
                var temp = $("#p_filenames_add").val()
                if (temp === ''){
                    $("#p_filenames_add").val(file.name+","+data.data+";2")
                }else {
                    $("#p_filenames_add").val(temp+"&"+file.name+","+data.data+";2")
                }
                console.log(data.data)
            });
            //移除文件触发的事件
            this.on("removedfile", function(file) {
                console.log(file.name)
                var fileName = $("#p_filenames_add").val()
                var str = fileName.split("&")
                for (var i = 0; i < str.length; i++){
                    if (str[i].indexOf(file.name) !== -1){
                        var f = str[i].substr(str[i].indexOf(",")+1)
                        deleteUpload(f)
                        str.splice(i,1)
                        console.log("File " + f + "removed");
                    }
                }
            });
        }
    });
</script>

</body>
</html>